package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    //通过电话来查询用户
    @Select("SELECT * FROM user where phone = #{phone} ;")
    User selectUserByPhone(String phone);

    //插入用户信息
    @Insert("INSERT INTO user( phone ,  status ) VALUES ( #{phone} , #{status} );")
    @Options(useGeneratedKeys = true , keyProperty =  "id")
    void addUser(User user1);

    @Select(" SELECT * FROM user where id = #{userId} ;")
    User findById(Long userId);
}
